package com.qian.ddj.web.controller;

import com.qian.api.ddj.model.Message;
import com.qian.api.ddj.service.IMessageService;
import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "信息处理")
@RequestMapping("ddj/message")
public class MessageController {
    @Autowired
    private IMessageService messageService;

    @PostMapping("/save")
    @ApiOperation("保存信息")
    public void save(Message message){
        messageService.save(message);
    }
    @GetMapping("/delete/{id}")
    @ApiOperation("通过ID删除信息")
    public void delete(@PathVariable Integer id){
        messageService.deleteById(id);
    }
    @GetMapping("/all")
    @ApiOperation("查询所有信息")
    public PageResp<Message> QueryMessage(PageReq pageReq){

        PageResp<Message> pageResp = messageService.findAll(pageReq);

        return pageResp;
    }
    @GetMapping("/{id}")
    @ApiOperation("通过ID查信息")
    public Message QueryMessageById(@PathVariable Integer id){
        Message message = messageService.findById(id);
        return message;
    }
}
